<?php session_start(); ?> 

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta content="text/html; charset=UTF-8" http-equiv="content-type"/>
<link rel="stylesheet" href="./css/ABC.css" type="text/css"/>
<script type="text/javascript" src="js/form.js"></script>
</head>
</html>

<?php
// @(#) $Id$
// +-----------------------------------------------------------------------+
// | Copyright (C) 2008, http://yoursite                                   |
// +-----------------------------------------------------------------------+
// | This file is free software; you can redistribute it and/or modify     |
// | it under the terms of the GNU General Public License as published by  |
// | the Free Software Foundation; either version 2 of the License, or     |
// | (at your option) any later version.                                   |
// | This file is distributed in the hope that it will be useful           |
// | but WITHOUT ANY WARRANTY; without even the implied warranty of        |
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the          |
// | GNU General Public License for more details.                          |
// +-----------------------------------------------------------------------+
// | Author: pFa                                                           |
// +-----------------------------------------------------------------------+
//
include("classes/ConnectionBDD.php");
include("classes/Formulaires.php");
include("classes/FormulairesI.php");
include("classes/portail.php");

$bdd = new Connector_Sql();
$frm = new Formulaires();
$frmI = new FormulairesI();
$port = new Portail();

mysql_connect('localhost','root','') or die('Connexion impossible a la BDD');
mysql_select_db('ABC PRO');

$frmI->debutFormulaire('Portail','portal','index.php');
$frm->ligne_vide();
$frmI->textbox('Login:','loginp');
$frmI->pwdbox('Mot de passe:','mdpp');
$frm->ligne_vide();
$frm->fin_formulaire();

//verifie l'utilisateur
if (isset($_POST['loginp']) and isset($_POST['mdpp'])) {

	$_SESSION['log'] = $_POST['loginp'];

	$log = $_SESSION['log'];

	$pwd = md5($_POST['mdpp']); //crypte le mot de passe
	
	if ($port->verifierUtilisateur($log,$pwd)) {
	
		$port->creerLog("Utilisateur \"".$log."\" s'est connecte a ","");
	
		switch ($port->chercherDroit($log)) {
			case 1:
    		echo "<script>window.location.replace(\"formulaires/droitadm.php\")</script>";
    	break;
			case 2:
    		echo "<script>window.location.replace(\"formulaires/droitint.php\")</script>";
    	break;
			case 3:
    		echo "<script>window.location.replace(\"formulaires/affInterventions.php\")</script>";
    	break;
		}
		
	}
	
}

$bdd->deconnect();

?>
